package com.ruicar.afs.cloud.apply.pre.loan.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.apply.common.entity.ApplyCustPersonalDetail;
import com.ruicar.afs.cloud.apply.pre.loan.mapper.ApplyCustPersonalMapper;
import com.ruicar.afs.cloud.apply.pre.loan.service.ApplyCustPersonalService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 个人客户明细service实现类
 * @Author:jihuigeng
 * @Date:2020/5/14 16:33
 * @Version: V1.0
 **/
@Service
public class ApplyCustPersonalServiceImpl extends ServiceImpl<ApplyCustPersonalMapper, ApplyCustPersonalDetail> implements ApplyCustPersonalService {

    /**
     * 通过申请编号获取客户明细列表
     *
     * @param applyNo
     * @return
     */
    public List<ApplyCustPersonalDetail> getCustPersonalDetailList(String applyNo) {

        List<ApplyCustPersonalDetail> detailList = this.baseMapper.selectList(Wrappers.<ApplyCustPersonalDetail>query().lambda()
                .eq(ApplyCustPersonalDetail::getApplyNo, applyNo));
        return detailList;
    }

    /**
     * 通过申请编号和客户ID查询客户明细
     *
     * @param applyNo
     * @param custId
     * @return
     */
    public ApplyCustPersonalDetail getCustPersonalDetail(String applyNo, Long custId) {

        ApplyCustPersonalDetail custPersonalDetail = this.baseMapper.selectOne(Wrappers.<ApplyCustPersonalDetail>query().lambda()
                .eq(ApplyCustPersonalDetail::getApplyNo, applyNo).eq(ApplyCustPersonalDetail::getCustId, custId));
        return custPersonalDetail;
    }

    /**
     * 通过申请编号和客户角色查询客户明细
     *
     * @param applyNo
     * @param custRole
     * @return
     */
    public ApplyCustPersonalDetail getPersonalDetailForMain(String applyNo, String custRole) {

        return this.baseMapper.getPersonalDetailForMain(applyNo, custRole);
    }
}
